package com.ysp.summary.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@SpringBootConfiguration
public class ThreadPoolConfig {

    public static final int coreSize = Runtime.getRuntime().availableProcessors();

    @Bean
    public ThreadPoolTaskExecutor threadPoolTaskExecutor(){
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setCorePoolSize(coreSize);
        taskExecutor.setMaxPoolSize(2*coreSize);
        taskExecutor.setQueueCapacity(32);
        taskExecutor.setThreadNamePrefix("ysp-create-");
        return taskExecutor;
    }
}
